<script>
import TitleA from "@/comps/comm/TitleA.vue";
import EzData from "@/comps/EzData.vue";
import formBuilder from "@/comps/form/formBuilder";
import apiTest from "@/pages/v1/xl/Test/js/apiTest";

export default {
  components: {EzData, TitleA},
  data(){
    let fb = formBuilder()
    fb.setLabelWidth(100)
    fb.addFiles("file","",12)
        .setFileIsFile()
        .setFileAccept(".xlsx")
    return{
      id:0,
      model:{
        test:0,
      },
      fb:fb,
    }
  },
  mounted() {
    this.id = this.$route.query.id * 1
    this.model.test = this.id
  },
  methods:{
    importData(){
      if (this.model.file === undefined){
        this.$toast.error("请选择文件")
        return
      }
      if (this.model.file.size > 1024 * 1024 * 10){
        this.$toast.error("文件大小不能超过10M")
        return
      }
      apiTest.imports(this.model, (res) => {
        console.log(res)
      })
    }
  }
}

</script>

<template>
  <div class="pad5">
    <mu-card class="pad10">
      <title-a>数据导入</title-a>
    </mu-card>
    <div>
      <mu-card class="pad10 mart10">
        <div class="">
          <EzData v-model="model" :config="fb"></EzData>
          <mu-button @click="importData">导入</mu-button>
          <div class="dev">{{model}}</div>
        </div>
      </mu-card>
    </div>
  </div>
</template>

<style scoped>

</style>